const joi = require("joi");
const page = joi.number().integer().min(1);
const limit = joi.number().integer().min(1).max(100);
const id = joi.number().required();
// 用户名的验证规则
// 账号名
const account = joi.string();
// 姓名
const userName = joi.string();
// 联系方式
const mobile = joi.string();
const avatar = joi.string();

// 密码
const password = joi.string().required();
// 性别
const gender = joi.number().valid(0, 1, 2).required();

const menuIds = joi.array().items(joi.number().integer());

// 新增条件验证规则对象
exports.reg_user_add_schema = {
  body: {
    account: account.required(),
    userName: userName.required(),
    mobile: mobile.required(),
    password,
    gender,
    avatar,
  },
};
// 编辑规则
exports.reg_user_edit_schema = {
  body: {
    id,
    account: account.required(),
    userName: userName.required(),
    mobile: mobile.required(),
    gender,
    avatar,
  },
};
// 用户绑定菜单
exports.reg_user_bindMenu_schema = {
  body: {
    id,
    menuIds,
  },
};
// 列表数据查询条件
exports.reg_user_delete_schema = {
  params: {
    id,
  },
};
// 列表数据查询条件
exports.reg_user_list_schema = {
  body: {
    page,
    limit,
    userName: userName.allow(""),
    mobile: mobile.allow(""),
  },
};
